package org.ms248462.controller;


import java.util.ArrayList;
import java.util.List;
import javax.ejb.EJB;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.ManagedProperty;
import javax.faces.bean.SessionScoped;
import javax.faces.model.DataModel;
import javax.faces.model.ListDataModel;
import org.ms24846.service.RssService;
import org.ms248462.domain.FeedMessage;

/**
 *
 * @author mszarl
 */
@ManagedBean
@SessionScoped
public class FeedController {
    @ManagedProperty(value="#{service}")
    private RssService service;
    public void setService(RssService service) {
        this.service = service;
    }
   
    private List<FeedMessage> messages = new ArrayList<FeedMessage>();

    public String getNewFeeds() {
        messages.clear();
        messages=service.getNewMessages();
        return null;
    }

    public DataModel getMessages() {
        return new ListDataModel<FeedMessage>(messages);
    }

    public int getCount() {
        return messages.size();
    }
}
